<template>
  <div class="app-container">
    <el-form :model="queryParams" :inline="true">
      <el-form-item>
        <el-input
          v-model="queryParams.title"
          placeholder="请输入标题"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          >删除</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table :data="richList">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="Id" type="index" align="center"></el-table-column>
      <el-table-column
        label="标题"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column label="url" align="center"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="handleUpdate(scope.row)"
            icon="el-icon-edit"
            size="mini"
            >修改</el-button
          >
          <el-button
            type="text"
            @click="handleDelete(scope.row)"
            icon="el-icon-delete"
            size="mini"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination :total="20" :current-page="1" :page-size="10"></pagination>

    <el-dialog
      :title="title"
      :visible.sync="open"
      append-to-body
      @close="reset"
    >
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="标签">
          <el-select placeholder="请选择" clearable style="width: 240px">
          </el-select>
        </el-form-item>
        <el-form-item label="标题">
          <el-input v-model="form.title" placeholder="请输入标题"></el-input>
        </el-form-item>
        <el-form-item label="内容">
          <Editor :height="300"></Editor>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "RichManager",
  data() {
    return {
      queryParams: {},
      form: {},
      richList: [],
      open: false,
      title: undefined,
    };
  },
  methods: {
    handleAdd() {
      this.open = true;
      this.title = "新增";
    },
    handleUpdate(row) {
      this.open = true;
      this.title = "修改";
    },
    confirm() {
      // 验证判断，成功后调用接口
    },
    cancel() {
      this.open = false;
      this.reset();
    },
    reset() {
      this.form = {};
    },
  },
};
</script>

<style></style>
